import org.apache.spark.sql.SparkSession
import org.apache.spark.{SparkConf, SparkContext}

object SourcePostgres {
  def main(args: Array[String]): Unit = {
    val sc = new SparkConf().setMaster("local[*]").setAppName("test")
    val spark = SparkSession.builder().config(sc).appName("test").master("local").getOrCreate()
    val jdbcDF = spark.read
      .format("jdbc")
      .option("url", "jdbc:postgresql://193.112.251.197:5432/datacenter")
      .option("dbtable", "dim.dim_xl_org")
      .option("user", "postgres")
      .option("password", "5LMHLV2eqP2zAST1")
      .load()

    jdbcDF.collect().foreach(println)
  }
}
